import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Layout from '../layout/index.vue'
import User from '../views/user/index.vue'
import HOME from '../views/home/index.vue'
import { HomeFilled, UserFilled, HelpFilled, Document, DataBoard, Comment, School } from "@element-plus/icons-vue";
// 动态  动态权限
export const asyncRoutes: any[] = [
  {
    path: "/home",
    title: 'HOME',
    component: Layout,
    meta: { icon: HomeFilled, til: "HOME" },
    children: [
      {
        path: "",
        title: 'HOME',
        component: HOME,
        meta: { til: "HOME" },
      }
    ]
  },
  {
    path: "/user",
    title: '用户管理',
    component: Layout,
    meta: { icon: UserFilled, til: "学生管理" },
    children: [
      {
        path: "",
        title: '用户列表',
        component: User,
        meta: { til: "用户列表" },
      }
    ]
  },
  {
    path: "/class",
    title: '学科管理',
    component: Layout,
    meta: { icon: HelpFilled, til: "学科管理" },
    children: [
      {
        path: "",
        title: '学科列表',
        component: () => import('../views/class/list.vue'),
        meta: { til: '学科列表' }
      },
      {
        path: "creat",
        title: '学科创编',
        component: () => import('../views/class/creat.vue'),
        meta: { til: '学科创编' }
      },
    ]
  },
  {
    path: "/test",
    title: '卷库管理',
    component: Layout,
    meta: { icon: Document, til: "卷库管理" },
    children: [
      {
        path: "",
        title: '试卷列表',
        component: () => import('../views/test/list.vue'),
        meta: { til: '试卷列表' }
      },
      {
        path: "edit",
        title: '试卷创编',
        component: () => import('../views/test/edit.vue'),
        meta: { til: '试卷创编' }
      }
    ]
  },
  {
    path: "/topic",
    title: '题库管理',
    component: Layout,
    meta: { icon: DataBoard, til: "题库管理" },
    children: [
      {
        path: '',
        title: '题目列表',
        component: () => import('../views/topic/list.vue'),
        meta: { til: '题目列表' }
      },
      {
        path: 'radio',
        title: '单选题创编',
        component: () => import('../views/topic/radio.vue'),
        meta: { til: '单选题创编' }
      },
      {
        path: 'truefalse',
        title: '判断题创编',
        component: () => import('../views/topic/trueFalse.vue'),
        meta: { til: '判断题创编' }
      },
      {
        path: 'shortanswer',
        title: '简答题创编',
        component: () => import('../views/topic/shortAnswer.vue'),
        meta: { til: '简答题创编' }
      },
    ]
  },
  {
    path: "/answer",
    title: '答卷管理',
    component: Layout,
    meta: { icon: Comment, til: "答卷管理" },
    children: [
      {
        path: '',
        title: '批改列表',
        component: () => import('../views/answer/list.vue'),
        meta: { til: '批改列表' }
      },
      {
        path: 'completeList',
        title: '试卷完成',
        component: () => import('../views/answer/completeList.vue'),
        meta: { til: '试卷完成', hidden: true}
      },
      {
        path: 'pdf',
        title: 'PDF导出',
        component: () => import('../views/answer/pdf.vue'),
        meta: { til: 'PDF', hidden: true }
      }
    ]
  },
  {
    path: "/analyze",
    title: '成绩分析',
    component: Layout,
    meta: { icon: School, til: "成绩分析" },
    children: [
      {
        path: '',
        title: '批改列表',
        component: () => import('../views/answer/completeList.vue'),
        meta: { til: '批改列表' }
      },
    ]
  },
]
// 静态 路由
export const staticRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/home',
    meta: {
      hidden: true
    }
  },
]

const router = createRouter({
  history: createWebHistory(),
  routes: [...staticRoutes, ...asyncRoutes],
});

export default router;